import { LoginParameters } from '@/types/login'
import request from '@/utils/request'
/** @module 账户管理 */
export function login(data: LoginParameters): Promise<any> {
  return request({
    url: '/account/login',
    data,
    method: 'POST',
    // 上传文件类型的时候设置
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function logout(): Promise<any> {
  return new Promise((resolve) => {
    resolve({
      code: '0000',
      msg: '成功',
      data: null
    })
  })
}

export function getUserInfo(): Promise<any> {
  return request({
    url: '/account/detail',
    method: 'POST'
  })
}

export function modifyPassword(data: any): Promise<any> {
  return request({
    url: '/account/modify-password',
    method: 'POST',
    data
  })
}

/** @module 用户管理 */
// 用户列表
export function getUserList(data: any): Promise<any> {
  return request({
    url: '/user/list',
    method: 'POST',
    data
  })
}

// 添加用户
export function addUser(data: any): Promise<any> {
  return request({
    url: '/user/add',
    method: 'POST',
    data
  })
}

// 删除用户
export function deleteUser(data: any): Promise<any> {
  return request({
    url: '/user/delete',
    method: 'POST',
    data
  })
}

// 编辑用户信息
export function updateUserInfo(data: any): Promise<any> {
  return request({
    url: '/user/update',
    method: 'POST',
    data
  })
}

// 编辑用户信息
export function resetPassword(data: any): Promise<any> {
  return request({
    url: '/user/reset-password',
    method: 'POST',
    data
  })
}
